package com.lagou.cluster.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lagou.cluster.mapper.UserMapper;
import com.lagou.cluster.pojo.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName LoginService
 * @Description
 * @Author playboy
 * @Date 2021/5/25 9:59 下午
 * @Version 1.0
 **/
@Service
public class LoginService {
	private static Logger log = LoggerFactory.getLogger(LoginService.class);

	@Autowired
	private UserMapper userMapper;

	public boolean login(String username, String password) {

		QueryWrapper<User> wrapper = new QueryWrapper<>();
		wrapper.eq("username", username);

		User user = userMapper.selectOne(wrapper);
		if (user == null) {
			return false;
		}
		if (user.getPassword().equals(password)) {
			return true;
		} else {
			return false;
		}
	}
}
